package com.example.seckilldemo.controller;


import com.example.seckilldemo.pojo.Order;
import com.example.seckilldemo.pojo.SeckillOrder;
import com.example.seckilldemo.service.IGoodsService;
import com.example.seckilldemo.service.IOrderService;
import com.example.seckilldemo.service.ISeckillOrderService;
import com.example.seckilldemo.vo.GoodsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lambyang
 * @since 2024-03-19
 */
@Controller
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private ISeckillOrderService seckillOrderService;
    @Autowired
    private IGoodsService goodsService;
    @Autowired
    private IOrderService orderService;


    @GetMapping("/detail")
    public String detail(Long orderId, Model model){
        SeckillOrder seckillOrder=seckillOrderService.getById(orderId);
        GoodsVo goodsVo=goodsService.findGoodsById(seckillOrder.getGoodsId());
        Order order=orderService.getById(seckillOrder.getOrderId());
        model.addAttribute("goods",goodsVo);
        model.addAttribute("order",order);
        return "orderDetail";
    }

}
